package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.bean.UserBean;
import com.zzj.service.UserService;
import com.zzj.utils.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api
//@CrossOrigin
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("findAll")
    public PageInfo<UserBean> findAll(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "5") int pageSize
    ){
        return userService.getAllUsers(pageNum,pageSize);
    }

    @PutMapping("updateState/{uid}/{ustate}")
    public Result updateStateById(@PathVariable("uid") int uid,@PathVariable("ustate") String ustate){
        return userService.updateStateById(uid,ustate);
    }
}
